[Unit]
Description=calico node
After=docker.service
Requires=docker.service

[Service]
User=root
Environment=ETCD_ENDPOINTS={{ etcd_cluster }}
PermissionsStartOnly=true
ExecStart=/usr/bin/docker run --net=host --privileged --name=calico-node \
  -e ETCD_ENDPOINTS=${ETCD_ENDPOINTS} \
  -e NODENAME=${HOSTNAME} \
  -e IP={{ node_ip }} \
  -e CALICO_IPV4POOL_CIDR=172.18.0.0/16 \
  -e AS={{ as_ids[inventory_hostname] }} \
  -e CALICO_LIBNETWORK_CREATE_PROFILES=true \
  -e CALICO_LIBNETWORK_ENABLED=true \
  -e CALICO_LIBNETWORK_LABEL_ENDPOINTS=false \
  -e CALICO_NETWORKING_BACKEND=bird \
  -e CALICO_IPV4POOL_IPIP=always \
  -e FELIX_IPINIPMTU=1480 \
  -v /var/run/calico:/var/run/calico \
  -v /lib/modules:/lib/modules \
  -v /run/docker/plugins:/run/docker/plugins \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v /var/log/calico:/var/log/calico \
  calico/node:v1.3.0

ExecStop=/usr/bin/docker rm -f calico-node
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target